package com.come4loves.game.module.skill.skillactorimpl;

import java.util.List;

import org.springframework.stereotype.Component;

import com.come4loves.game.module.fight.action.CardToLocationAction;
import com.come4loves.game.module.fight.constants.CardLocation;
import com.come4loves.game.module.fight.model.FightCard;
import com.come4loves.game.module.fight.model.FightContext;
import com.come4loves.game.module.skill.AbstractSkillActorParser;
import com.come4loves.game.module.skill.model.SkillModel;
@Component
public class GetCardSkill extends AbstractSkillActorParser {

	@Override
	public String skillId() {
		return "drawcard";
	}

	@Override
	public void handerSkill(SkillModel skillModel, FightContext fightContext) {
		int effectValue = Integer.valueOf(skillModel.getEffect().get(skillId()));
		
		List<FightCard> cards = fightContext.beActorBattle.takeCard(effectValue);
		for (FightCard fightCard : cards) {
			CardToLocationAction cardToLocationAction = CardToLocationAction.createFromCard(fightCard, CardLocation.HAND);
			fightContext.actionRecorder.addAction(cardToLocationAction);
			LOGGER.debug("drawcard:{}" , fightCard);
		}
	}

}
